<template>
  <div style="text-align:center;margin:auto;width:710px">
    <div id="programme" style="width:710px" ref="print">
      <ncgctTemplate></ncgctTemplate>
    </div>
    <div class="error500-btn-con">
      <el-button @click="myprint" style="width: 200px;margin-top:10px" type='primary'>打印</el-button>
    </div>
  </div>
</template>
<script>
import html2canvas from 'html2canvas'
import ncgctTemplate from './ncgctTemplate'
export default {
  name: 'ncgct',
  components: {
    ncgctTemplate
  },
  data() {
    return {
      data: [],
      activeName: 'main'
    }
  },
  created() {},
  mounted() {},
  methods: {
    myprint() {
      this.loading = true
      this.$message.success('后台正在打包,请稍候。。。')
      var dom = document.getElementById('programme')
      html2canvas(dom).then(canvas => {
        const url = canvas.toDataURL()
        var newstr = `<img src="${url}" width="100%"/>`
        var tab = window.open('', '打印')
        tab.document.open()
        tab.document.write(newstr)
        setTimeout(() => {
          tab.window.print()
          tab.close()
          this.loading = false
        }, 0)
      })
    }
  },
  computed: {},
  props: []
}
</script>